package com.example.until;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.List;
import java.util.Map;

public class RwriteContent {
	
	private Map<String, String> colum;
	
	private final String flag = "public class"; 
	
	private String filePathPerfix = "/src/mian/java/";
	
	private Class<?> className;
	
	private final String attributePerfix = "private String ";
	
	public RwriteContent(Map<String, String> colum, Class<?> className)
	{
		this.colum = colum;
		
		this.className = className;
	}

	public Map<String, String> getColum() {
		return colum;
	}

	public void setColum(Map<String, String> colum) {
		this.colum = colum;
	}
	
	
	public boolean write()
	{
		
		FileUntil fileUntil = new FileUntil(this.filePathPerfix+this.className.getName().replace(".", "/")+".java", this.flag);
			
		fileUntil.write(this.buildStr());
			
		
		
		return true;
	}
	
	/**
	 * 获取文件总行数
	 */
	/**
	 * 指定行 写入
	 */
	public String buildStr ()
	{
		StringBuilder build = new StringBuilder();
		
		for (String str : this.colum.keySet()) {
			build.append(this.attributePerfix + this.colum.get(str) + ";\r\n");
		}
		
		return build.toString();
	}
	
	
}
